<?php

namespace App\Console\Commands;

use App\Events\BackendNoticeEvent;
use App\Events\DeviceStatusChange;
use App\Jobs\BaiduPushOrderEndedMsg;
use App\Events\CreateOrder;
use App\Events\OrderStatusChange;
use App\Jobs\SendMobileSms;
use App\Jobs\WechatPushOrderEndedMsg;
use App\Tables\Device;
use App\Tables\Order;
use App\Tables\User;
use Carbon\Carbon;
use Illuminate\Console\Command;
use OperationLog;
use XmtApp\Payment\Alipay\Alipay;
use MobileSms;
use App\Tables\Region;
use EasyWeChat;

class Test extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'test:test';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $order = Order::where('order_sn', '20180401085AC0D0FE880A8')->first();
//        dispatch(new BaiduPushOrderEndedMsg($order));
//        event(new CreateOrder($order));
//        event(new OrderStatusChange('20171224115A3FCA4EB4567', 'stop'));
//
//        $location = get_baidu_point_for_ip('36.40.23.15', config('baidu.ak'));
//
//        var_export($location);

//        OperationLog::info('测试消息日志', '测试日志内容');
//        OperationLog::error('测试错误日志', '测试日志内容');
//        OperationLog::debug('测试调试日志', '测试日志内容');
//        OperationLog::warn('测试警告日志', '测试日志内容');

//        $alipay = resolve(Alipay::class);
//
//        var_export($alipay);

//        echo Carbon::now()->format('m月d日h时i分');
//        $code = random_int(1000, 9999);
//
//        $sms = MobileSms::makeAuthCode('18829553701', $code,
//            "验证码为【{$code}】加电侠进行注册业务，请将验证码输入，如非本人操作请勿泄露。【加电侠】", 'register');
//
//        dispatch(new SendMobileSms($sms));

//        $res = MobileSms::verifyAuthCode('18829553702', '829857', 60);
////
//        if ($res) {
//            $this->info('有效');
//        } else {
//            $this->error('无效');
//        }

//        event(new DeviceStatusChange(Device::where('device_sn', '17122617045A4210A81D0CF')->first()));
//
//        event(new BackendNoticeEvent('测试', 1));

//        $regions = Region::whereIn('code', [110000, 110100,110101])->get(['name']);
//
//        var_export($regions->implode('name', ''));

//        $this->info(str_slug('我的中国心', '-'));

//        $this->info(resource_path('assets/js/webapp/images/logo.jpg'));

        dispatch(new WechatPushOrderEndedMsg($order));
    }
}
